﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using SES.CMS.BL;
using SES.CMS.DO;

namespace SES.CMS
{
    public partial class Articles : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            rptListArticleDataSource();
        }

        protected void rptListArticleDataSource()
        {
            DataTable dtListArtile = null;
            if (!string.IsNullOrEmpty(Request.QueryString["ID"]))
            {
                int CateID = int.Parse(Request.QueryString["ID"].ToString());
                dtListArtile = new cmsArticleBL().SelectByCategoryID(CateID);
                lblAboutTitle.Text = new cmsCategoryBL().Select(new cmsCategoryDO{CategoryID = CateID}).Title;
            }
            else
            {
                dtListArtile = new cmsArticleBL().SelectAll();
                lblAboutTitle.Text = "News";
            }

            CollectionPager1.MaxPages = 10000;

            CollectionPager1.PageSize = 15; // số items hiển thị trên một trang

            CollectionPager1.DataSource = dtListArtile.DefaultView;

            CollectionPager1.BindToControl = rptListArticle;
            rptListArticle.DataSource = CollectionPager1.DataSourcePaged;
            rptListArticle.DataBind();

            
        }

        public string FriendlyUrl(string s)
        {
            return Ultility.Change_AV(s);
        }
        public string WordCut(string s)
        {
            return Ultility.WordCut(s, 200, new char[] { ' ', '.', ',', ';' }) + "...";
        }
    }
}
